package com.you.pattern.observer.demo1;

import java.util.Observable;

/**
 * 被观察者
 */
public class GPer extends Observable {
    private String name = "GPer 生态圈";

    private static GPer gPer = null;

    private GPer() {
    }

    public static GPer getInstance() {
        if (null == gPer) {
            return new GPer();
        } else {
            return gPer;
        }
    }

    public String getName() {
        return name;
    }

    public void publishQuestion(Question question) {
        System.out.println(question.getUserName() + "在" + this.name + "上提交了一个问题。");
        setChanged();
        notifyObservers(question);
    }
}
